define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'admissions/index' + location.search,
                    add_url: 'admissions/add',
                    edit_url: 'admissions/edit',
                    del_url: 'admissions/del',
                    multi_url: 'admissions/multi',
                    import_url: 'admissions/import',
                    table: 'admissions',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {
                            field: 'sex',
                            title: __('Sex'),
                            searchList: {"1": '男', "2": '女'},
                            formatter: Table.api.formatter.label
                        },
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'id_card', title: __('Id_card')},
                        {field: 'enrollment_teacher', title: __('Enrollment_teacher')},
                        {field: 'school', title: __('School'), operate: 'LIKE'},
                        {field: 'grade', title: '年级', operate: 'LIKE'},
                        {field: 'headmaster', title: '班主任', operate: 'LIKE'},
                        {field: 'professional', title: __('Professional'), operate: 'LIKE'},
                        {field: 'standard_tuition', title: __('Standard_tuition'), operate:'BETWEEN'},
                        {field: 'bmzc', title: __('Bmzc'), operate: 'LIKE'},
                        {field: 'xingshi', title: __('Xingshi'), searchList: {"0":'请选择',"1":'函授',"2":'国开'}, formatter: Table.api.formatter.normal},
                        {field: 'actual_cost', title: __('Actual_cost'), operate:'BETWEEN'},
                        {field: 'jfjt_images', title: __('Jfjt_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'other_content', title: __('Other_content'), operate: false},
                        {field: 'remarks', title: '老师备注', operate: false},
                        {field: 'status', title: __('Status'), searchList: {"0":'未完成',"1":'已完成'}, formatter: Table.api.formatter.normal},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
